function RequestUtils() {
};

RequestUtils.prototype._read = function(name, cond_vals, page, size, order, queue, callbackFunc, options) {
  var php = (options && options.php) ? options.php : Constant.READ;
  var request = new Request(this._parseRead, { method: 'POST', context: this, params: { callbackFunc: RequestUtils.callbackFunc((options) ? options.pos : null, 'Reading...', callbackFunc, (options && options.doc) ? options.doc : document), options: options } });
  request._request(php + '?name=' + encodeURIComponent(name), ((cond_vals) ? '&c=' + JSON.stringify(cond_vals) : '') + ((page) ? '&p=' + encodeURIComponent(page) : '') + ((size) ? '&s=' + encodeURIComponent(size) : '') + ((order) ? '&o=' + encodeURIComponent(order) : '') + ((queue) ? '&q=' + encodeURIComponent(queue) : ''));
};

RequestUtils.prototype._parseRead = function(result, params) {
  if (params.callbackFunc) {
    params.callbackFunc(result, params);
  }
};

RequestUtils.prototype._write = function(query, callbackFunc, options) {
  var php = (options && options.php) ? options.php : Constant.WRITE;
  var request = new Request(this._parseWrite, { method: 'POST', context: this, params: { callbackFunc: RequestUtils.callbackFunc((options) ? options.pos : null, 'Writing...', callbackFunc, (options && options.doc) ? options.doc : document), options: options } });
  request._request(php, 'q=' + encodeURIComponent(query));
};

RequestUtils.prototype._parseWrite = function(result, params) {
  if (params.callbackFunc) {
    params.callbackFunc(result, params);
  }
};

RequestUtils.prototype._custom = function(action, query, callbackFunc, options) {
  var php = (options && options.php) ? options.php : Constant.CUSTOM;
  var request = new Request(this._parseCustom, { method: 'POST', context: this, params: { callbackFunc: RequestUtils.callbackFunc((options) ? options.pos : null, 'Waiting...', callbackFunc, (options && options.doc) ? options.doc : document), options: options } });
  request._request(php + '?action=' + encodeURIComponent(action), ((query) ? 'q=' + encodeURIComponent(query) : ''));
};

RequestUtils.prototype._parseCustom = function(result, params) {
  if (params.callbackFunc) {
    params.callbackFunc(result, params);
  }
};

RequestUtils.callbackFunc = function(pos, text, callbackFunc, doc) {
  if (pos) {
    var popupBox = new ModulePopupBoxSimple();
    MiscUtils.load(popupBox, pos, text);
    return function(result, params) { callbackFunc(result, params);
                                      popupBox._close();
                                    };
  } else {
    return callbackFunc;
  }
};
